package com.moleq.mgnetwork;

import java.io.File;

import android.content.Context;

public class ContextManager {

	public Context createContext(Context context, String packageName) {
		Context sharedContext = null;
		try {
			sharedContext = context.createPackageContext(packageName, Context.CONTEXT_IGNORE_SECURITY);
			if (sharedContext == null) {
				return context;
			}
		} catch (Exception e) {
//			String error = e.getMessage();
//			return context;
			e.printStackTrace();
		}

		return sharedContext;
	}

	public String getDbPath(Context context, String packageName, String dbfileName) {
		String result = "";
		Context shareContext = null;
		shareContext = createContext(context, packageName);

		if (shareContext != null) {
			result = shareContext.getDatabasePath(dbfileName).getAbsolutePath();
//			if (!new File(result).exists()) {
//				result = "";
//			}
		}

		return result;
	}
}
